home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Syn Text Editor 2.1.0.46 / synsetup-2.1.0.46.exe / {app} / scripts / selblock.vbs < prev    next >
Text File  |  2003-09-14  |  5KB  |  177 lines

  1. ' Caption: Select Block|
  2. ' Hint: Select Block in active editor|
  3. ' Icon: |
  4. '
  5. '  syn
  6. '  Copyright (C) 2000-2003, Ascher Stefan. All rights reserved.
  7. '  stievie@utanet.at, http://web.utanet.at/ascherst/
  8. '
  9. '  The contents of this file are subject to the Mozilla Public License
  10. '  Version 1.1 (the "License"); you may not use this file except in compliance
  11. '  with the License. You may obtain a copy of the License at
  12. '  http://www.mozilla.org/MPL/
  13. '
  14. '  Software distributed under the License is distributed on an "AS IS" basis,
  15. '  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  16. '  the specific language governing rights and limitations under the License.
  17. '
  18. '  The Original Code is selblock.vbs, released Sun, 26 May 2002 10:55:39 UTC.
  19. '
  20. '  The Initial Developer of the Original Code is Ascher Stefan.
  21. '  Portions created by Ascher Stefan are Copyright (C) 2000-2003 Ascher Stefan.
  22. '  All Rights Reserved.
  23. '
  24. '  Contributor(s): .
  25. '
  26. '  Alternatively, the contents of this file may be used under the terms of the
  27. '  GNU General Public License Version 2 or later (the "GPL"), in which case
  28. '  the provisions of the GPL are applicable instead of those above.
  29. '  If you wish to allow use of your version of this file only under the terms
  30. '  of the GPL and not to allow others to use your version of this file
  31. '  under the MPL, indicate your decision by deleting the provisions above and
  32. '  replace them with the notice and other provisions required by the GPL.
  33. '  If you do not delete the provisions above, a recipient may use your version
  34. '  of this file under either the MPL or the GPL.
  35. '
  36. '  You may retrieve the latest version of this file at the syn home page,
  37. '  located at http://syn.sourceforge.net/
  38. '
  39. ' $Id: selblock.vbs,v 1.3.2.6 2003/09/14 17:52:56 neum Exp $
  40.  
  41. option explicit
  42.  
  43. '#include <consts>
  44.  
  45. dim txtBX, txtBY, txtEX, txtEY
  46. dim btnOK, btnCancel
  47.  
  48. sub FormShow(Sender)
  49.   txtBX.Text = CStr(ActiveDocument.BlockBeginX)
  50.   txtBY.Text = CStr(ActiveDocument.BlockBeginY)
  51.   txtEX.Text = CStr(ActiveDocument.BlockEndX)
  52.   txtEY.Text = CStr(ActiveDocument.BlockEndY)
  53. end sub
  54.  
  55. sub EditChange(Sender)
  56.   btnOK.Enabled = IsNumeric(txtBX.Text) and IsNumeric(txtBY.Text) and _
  57.   IsNumeric(txtBY.Text) and IsNumeric(txtEY.Text)
  58. end sub
  59.  
  60. sub EditKeyPress(Sender, Key)
  61.   const IntChars = "1234567890"
  62.   if InStr(Key, IntChars) = 0 then
  63.     Key = 0
  64.   end if
  65. end sub
  66.  
  67. sub Main(dummy)
  68.   if Documents.Count = 0 then
  69.     MsgBox "No Document open.", vbCritical
  70.     exit sub
  71.   end if
  72.   dim Form
  73.   dim lblBX, lblBY, lblEX, lblEY
  74.   Form = Create("TForm", Self)
  75.   with Form
  76.     .Caption = "Select Block"
  77.     .Position = "poOwnerFormCenter"
  78.     .BorderStyle = "bsDialog"
  79.     .Width = 215
  80.     .Height = 123
  81.     .OnShow = "FormShow"
  82.   end with
  83.   txtBX = Create("TEdit", Form)
  84.   with txtBX
  85.     .Parent = Form
  86.     .Left = 55
  87.     .Top = 8
  88.     .Width = 50
  89.     .Height = 21
  90.     .OnChange = "EditChange"
  91.   end with
  92.   lblBX = Create("TLabel", Form)
  93.   with lblBX
  94.     .Parent = Form
  95.     .Caption = "&Begin X:"
  96.     .Left = 8
  97.     .Top = 12
  98.     .FocusControl = txtBX
  99.   end with
  100.   txtBY = Create("TEdit", Form)
  101.   with txtBY
  102.     .Parent = Form
  103.     .Left = 55
  104.     .Top = 30
  105.     .Width = 50
  106.     .Height = 21
  107.     .OnChange = "EditChange"
  108.   end with
  109.   lblBY = Create("TLabel", Form)
  110.   with lblBY
  111.     .Parent = Form
  112.     .Caption = "B&egin Y:"
  113.     .Left = 8
  114.     .Top = 34
  115.     .FocusControl = txtBY
  116.   end with
  117.   txtEX = Create("TEdit", Form)
  118.   with txtEX
  119.     .Parent = Form
  120.     .Left = 150
  121.     .Top = 8
  122.     .Width = 50
  123.     .Height = 21
  124.     .OnChange = "EditChange"
  125.   end with
  126.   lblEX = Create("TLabel", Form)
  127.   with lblEX
  128.     .Parent = Form
  129.     .Caption = "End &X:"
  130.     .Left = 110
  131.     .Top = 12
  132.     .FocusControl = txtEX
  133.   end with
  134.   txtEY = Create("TEdit", Form)
  135.   with txtEY
  136.     .Parent = Form
  137.     .Left = 150
  138.     .Top = 30
  139.     .Width = 50
  140.     .Height = 21
  141.     .OnChange = "EditChange"
  142.   end with
  143.   lblEY = Create("TLabel", Form)
  144.   with lblEY
  145.     .Parent = Form
  146.     .Caption = "End &Y:"
  147.     .Left = 110
  148.     .Top = 34
  149.     .FocusControl = txtEY
  150.   end with
  151.   btnCancel = Create("TButton", Form)
  152.   with btnCancel
  153.     .Parent = Form
  154.     .Top = 65
  155.     .Caption = "Cancel"
  156.     .Left = 126
  157.     .Cancel = true
  158.     .ModalResult = mrCancel
  159.   end with
  160.   btnOK = Create("TButton", Form)
  161.   with btnOK
  162.     .Parent = Form
  163.     .Top = 65
  164.     .Caption = "OK"
  165.     .Left = 46
  166.     .Default = true
  167.     .ModalResult = mrOK
  168.   end with
  169.   
  170.   if Form.ShowModal = mrOK then
  171.     ActiveDocument.SelectRange CInt(txtBX.Text), CInt(txtBY.Text), _
  172.     CInt(txtEX.Text), CInt(txtEY.Text)
  173.   end if
  174.   
  175.   Form.Free
  176. end sub
  177.